/* PowerPC Trap Handler first Half */
        .text
        .globl mmumain
        .globl _mmumain
mmumain:
        mr 0,1
        lis 1,2
        subi 1,1,448
        stw 0,20(1)
        stw 2,24(1)
	stw 3,28(1)
	stw 4,32(1)
	stw 5,36(1)
	stw 6,40(1)
	stw 7,44(1)
	stw 8,48(1)
	stw 9,52(1)
        stw 10,56(1)
	stw 11,60(1)
	stw 12,64(1)
	stw 13,68(1)
	stw 14,72(1)
	stw 15,76(1)
	stw 16,80(1)
	stw 17,84(1)
	stw 18,88(1)
	stw 19,92(1)
	stw 20,96(1)
        stw 21,100(1)
        stw 22,104(1)
	stw 23,108(1)
	stw 24,112(1)
	stw 25,116(1)
	stw 26,120(1)
	stw 27,124(1)
	stw 28,128(1)
	stw 29,132(1)
	stw 30,136(1)
	stw 31,140(1)
	mfsrr0 0
	stw 0,400(1)
	mfmsr 0
	stw 0,404(1)
	mfcr 0
	stw 0,408(1)
	mflr 0
	stw 0,412(1)
	mfctr 0
	stw 0,416(1)
	mfdsisr 0
	stw 0,420(1)
	mfdar 0
	stw 0,424(1)
        mfxer 0
	stw 0,428(1)
        addi 7,1,16
        lis 8,_mmumain@ha
        addi 8,8,_mmumain@l
        mtctr 8
	bctrl
        addi 1,1,16
	lwz 2,8(1)
	/* Don't reload r3, since we'll return a result */
	lwz 4,16(1)
	lwz 5,20(1)
	lwz 6,24(1)
	lwz 7,28(1)
	lwz 8,32(1)
	lwz 9,36(1)
	lwz 10,40(1)
	lwz 11,44(1)
	lwz 12,48(1)
	lwz 13,52(1)
	lwz 14,56(1)
	lwz 15,60(1)
	lwz 16,64(1)
	lwz 17,68(1)
	lwz 18,72(1)
	lwz 19,76(1)
	lwz 20,80(1)
	lwz 21,84(1)
	lwz 22,88(1)
	lwz 23,92(1)
	lwz 24,96(1)
	lwz 25,100(1)
	lwz 26,104(1)
	lwz 27,108(1)
	lwz 28,112(1)
	lwz 29,116(1)
	lwz 30,120(1)
	lwz 31,124(1)
	lwz 0,392(1)
	mtcr 0
        lwz 0,396(1)
        mtsrr0 0
        lwz 0,400(1)
        mtctr 0
	lwz 0,388(1) /* Copy out new MSR bits if needed */
	lwz 1,4(1)
        mtsrr1 0
        rfi

        .globl trap_start
        .globl trap_end
trap_start:
        mtsprg1 1
        lis 1,2
        subi 1,1,448
        stw 0,16(1)
        mfsprg1 0
        stw 0,20(1)
        stw 2,24(1)
	stw 3,28(1)
	stw 4,32(1)
	stw 5,36(1)
	stw 6,40(1)
	stw 7,44(1)
	stw 8,48(1)
	stw 9,52(1)
        stw 10,56(1)
	stw 11,60(1)
	stw 12,64(1)
	stw 13,68(1)
	stw 14,72(1)
	stw 15,76(1)
	stw 16,80(1)
	stw 17,84(1)
	stw 18,88(1)
	stw 19,92(1)
	stw 20,96(1)
        stw 21,100(1)
        stw 22,104(1)
	stw 23,108(1)
	stw 24,112(1)
	stw 25,116(1)
	stw 26,120(1)
	stw 27,124(1)
	stw 28,128(1)
	stw 29,132(1)
	stw 30,136(1)
	stw 31,140(1)
	mfsrr0 0
	stw 0,400(1)
	mfsrr1 0
	stw 0,404(1)
	mfcr 0
	stw 0,408(1)
	mflr 0
	stw 0,412(1)
	mfctr 0
	stw 0,416(1)
        mfdsisr 0
	stw 0,420(1)
        mfdar 0
	stw 0,424(1)
	mfxer 0
	stw 0,428(1)
        bl 1f
1:      mflr 5
        addi 4,1,16
        rlwinm 3,5,24,0xff
        lwz 5,36(5)
        mtctr 5
	lis 5,trap_finish_start@ha
	addi 5,5,trap_finish_start@l
	mtlr 5
	bctr
trap_end:
	.space 4
        
       	.globl trap_finish_start
trap_finish_start:
        addi 1,1,16
	lwz 2,8(1)
	lwz 3,12(1)
	lwz 4,16(1)
	lwz 5,20(1)
	lwz 6,24(1)
	lwz 7,28(1)
	lwz 8,32(1)
	lwz 9,36(1)
	lwz 10,40(1)
	lwz 11,44(1)
	lwz 12,48(1)
	lwz 13,52(1)
	lwz 14,56(1)
	lwz 15,60(1)
	lwz 16,64(1)
	lwz 17,68(1)
	lwz 18,72(1)
	lwz 19,76(1)
	lwz 20,80(1)
	lwz 21,84(1)
	lwz 22,88(1)
	lwz 23,92(1)
	lwz 24,96(1)
	lwz 25,100(1)
	lwz 26,104(1)
	lwz 27,108(1)
	lwz 28,112(1)
	lwz 29,116(1)
	lwz 30,120(1)
	lwz 31,124(1)
	lwz 0,384(1)
	mtsrr0 0
	lwz 0,388(1)
	mtsrr1 0
	lwz 0,392(1)
	mtcr 0
        lwz 0,396(1)
        mtlr 0
        lwz 0,400(1)
        mtctr 0
        lwz 0,404(1)
        mtdsisr 0
        lwz 0,412(1)
        mtdar 0
        lwz 0,416(1)
        mtxer 0
        lwz 0,0(1)
	lwz 1,4(1)
	rfi
